package com.blackhorse.stream.producer;

import com.blackhorse.stream.channel.MyProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

//自定义发送端
@Component
@EnableBinding(MyProcessor.class)
public class MyMessageSender {

    @Autowired
    @Qualifier("myoutput")
    private MessageChannel myoutput;

    public void send(Object obj) {
        myoutput.send(MessageBuilder.withPayload(obj).build());
    }
}
